# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libpsl
pkgver=0.21.5
pkgrel=1
pkgdesc="C library for the Publix Suffix List"
url="https://rockdaboot.github.io/libpsl"
arch="all"
license="MIT"
depends_dev="$pkgname-utils=$pkgver-r$pkgrel"
makedepends="python3 libidn2-dev libunistring-dev meson"
subpackages="$pkgname-static $pkgname-utils $pkgname-dev $pkgname-doc"
source="https://github.com/rockdaboot/libpsl/releases/download/$pkgver/libpsl-$pkgver.tar.gz"

build() {
	# -Db_lto=true does not work when cross-compiling
	if [ "$CBUILD" != "$CHOST" ];then
		_b_lto_configure="-Db_lto=false"
	else
		_b_lto_configure="-Db_lto=true"
	fi
	abuild-meson \
		--default-library=both \
		$_b_lto_configure \
		. output
	meson compile -C output
}

check() {
	meson test --no-rebuild --print-errorlogs -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

utils() {
	pkgdesc="$pkgdesc (utils)"

	amove usr/bin
}

sha512sums="
c14d575cecc0f1693894dd79565b6b9220084ddfa43b908a1cefe16d147cdd5ec47796eb0c2135e2f829a951abaf39d8a371ab5c1352f57b36e610e25adf91f5  libpsl-0.21.5.tar.gz
"
